package entities;

import java.util.List;

import javax.persistence.Column;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import exceptions.ArgomentoNonValido;



@Entity
@Table(name="registrato")


public class RegistratoEB implements java.io.Serializable {
	
	
	private static final long serialVersionUID = -268155864385998476L;
	
	@Column(name="mail")
	private String mail;
	
	@Column(name="nomeU")
	private String nomeU;
	
	@Column(name="password")
	private String password;
	
	@Column(name="nome")
	private String nome;
	
	@Column(name="cognome")
	private String cognome;
	
	@Column(name="dataN")
	private String dataN;
	
	@Column(name="cf")
	private String cf;
	
	@OneToMany
	@JoinColumn(name="mail")
	private List<RegistratoEB> amici;
	
	@OneToMany
	@JoinColumn(name="idabilita")
	private List<Abilita> abilita;
	
	
	
	
	public RegistratoEB (){
		
	}
	

	public RegistratoEB(String mail, String nomeU, String password, String nome, String cognome, String dataN, String cf) throws ArgomentoNonValido {
		
		if(mail != null && nomeU!=null && password!= null && nome!= null && cognome!= null && dataN!= null &&  cf!= null){
			this.mail=mail;
			this.cf = cf;
	    	this.nomeU = nomeU;
	    	this.password = password;
	    	this.nome = nome;
	    	this.cognome = cognome;
	    	this.dataN = dataN;
	    	this.cf = cf;
	    	
		}else {
			throw new ArgomentoNonValido();
		}
		
		
		
	}
	
	
	@Id
    @Column(name="mail")
	public String getMail() {
		return mail;
	}
	
	
	
	 @Column(name="cf")
	public String getCf() {
		return cf;
	}
	 
	
	 @Column(name="nomeU")
	 public String getNomeU() {
			return nomeU;
		}
	 
	 
	 @Column(name="password")
	 public String getPassword() {
			return password;
		}
	 
	 
	 @Column(name="nome")
	 public String getNome() {
			return nome;
		}
	 
	 
	 @Column(name="cognome")
	 public String getCognome() {
			return cognome;
		}
	 
	 @Column(name="dataN")
	 public String getDataN() {
			return dataN;
		}


	public List<Abilita> getAbilita() {
		return abilita;
	}


	public void setAbilita(List<Abilita> abilita) {
		this.abilita = abilita;
	}


	public List<RegistratoEB> getAmici() {
		return amici;
	}


	public void setAmici(List<RegistratoEB> amici) {
		this.amici = amici;
	}
	
	
	
	
}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	






